/**
 * 玩家钻石组件
 */
var DiamondUnit = Unit.extend({
    /**
     * 微信商店地址
     * @private
     * @const
     */
    WX_SHOP_URL: 'http://pay.yayayouxi.com/payServer/commodity/findCommodityInfoListByArea',
    _ccsFileName: res.DiamondUnit_json,
    initUnit:function(){
    },
    /**
     * 初始化钻石
     * @protected
     */
    refreshData: function () {
        if (gameData.diamondnum == null) {
            cc.error('CoinUnit._initMoney gameData.diamondnum is null');
            return;
        }
        var _money = equalNumDot2(gameData.diamondnum);
        this._nodeList['Click_roomcard.txtCount'].setString(_money);
    },
    _initClickListeners: function () {
        this._super();
        this._clickListeners = {
            'Click_roomcard': '_clickCard'
        };
    },
    _initEventListeners: function () {
        Unit.prototype._initEventListeners.call(this);
        this._eventListeners[EventKey.UpdateFk] = "setData";
    },
    /**
     * 点击房卡
     * @private
     */
    _clickCard: function () {
        //showWindow('CoinShopWindow',CoinShopType.Diamond);
    },
    /**
     * 请求微信商店
     * @private
     */
    _requestWXShop: function () {
        showLoading("努力加载中..");
        var sendData = {area: app.parent_area, playerid: gameData.uid, unionid: gameData.unionid};
        http.post(this.WX_SHOP_URL, sendData, this._requestWXShopSuccess.bind(this), this._requestWXShopFailure.bind(this));
    },
    /**
     * 请求微信商店成功
     * @private
     */
    _requestWXShopSuccess: function (data) {
        hideLoading();
        if (!data) {
            showAlert('请求数据异常！');
            return;
        }
        this.addChild(new WxShopLayer(data));
    },
    /**
     * 请求微信商店失败
     * @private
     */
    _requestWXShopFailure: function () {
        hideLoading();
        showAlert('商店请求失败，请检查网络');
    }
});